package com.newtouch.bxzs.business.statistics.controller;

import com.newtouch.bxzs.business.config.MyLog;
import com.newtouch.bxzs.business.statistics.model.bo.*;
import com.newtouch.bxzs.business.statistics.model.vo.AchievementMonthlyDetailVO;
import com.newtouch.bxzs.business.statistics.model.vo.AchievementRankingVO;
import com.newtouch.bxzs.business.statistics.model.vo.AchievementSummaryVO;
import com.newtouch.bxzs.business.statistics.service.AchievementService;
import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 个人业绩控制类
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/1/7</td>
 * <td>tianshangzhu</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author tianshangzhu
 * @version 1.0.0
 * @since 1.0.0
 */
@Api(tags = "业绩接口")
@RestController
@RequestMapping("/personalAchievementController")
@SuppressWarnings("unchecked")
public class PersonalAchievementController {

	/**
	 * 静态变量：系统日志
	 */
	private static final Log logger = LogFactory.getLog(PersonalAchievementController.class);

	@Autowired
	private AchievementService achievementService;

	@ApiOperation(value = "查询个人业绩汇总列表")
	@PostMapping("/getAchievementSummaryByOrg")
	@MyLog(systemFunctionName = "个人业绩",systemFunctionUrl = "/personalAchievementController/getAchievementSummaryByOrg",userOperationType = 4,userOperationSummary = "查询个人业绩汇总列表")
	public BaseResponse<AchievementSummaryBO> getAchievementSummaryByOrg(
			@RequestBody AchievementSummaryVO achievementPolicyDetailVO) {
		logger.info("查询个人业绩汇总列表");
		return RespGenerator.returnOK(achievementService.getAchievementSummaryByOrg(achievementPolicyDetailVO));
	}

	@ApiOperation(value = "查询个人业绩月度明细")
	@PostMapping("/getPersonalAchievementMonthlyDetail")
	@MyLog(systemFunctionName = "个人业绩",systemFunctionUrl = "/personalAchievementController/getPersonalAchievementMonthlyDetail",userOperationType = 4,userOperationSummary = "查询个人业绩月度明细")
	public BaseResponse<List<AchievementPolicyBO>> getPersonalAchievementMonthlyDetail(
			@RequestBody AchievementMonthlyDetailVO achievementMonthlyDetailVO) {
		logger.info("查询个人业绩月度明细详细");
		return RespGenerator.returnOK(achievementService.getPersonalAchievementMonthlyDetail(achievementMonthlyDetailVO));
	}

	@ApiOperation(value = "查询个人业绩保单明细")
	@GetMapping("/getAchievementPolicyDetail")
	@MyLog(systemFunctionName = "个人业绩",systemFunctionUrl = "/personalAchievementController/getAchievementPolicyDetail",userOperationType = 4,userOperationSummary = "查询个人业绩保单明细")
	public BaseResponse<AchievementPolicyDetailBO> getAchievementPolicyDetail(
			@RequestParam("policyNumber") String policyNumber) {
		logger.info("查询个人业绩保单详细");
		return RespGenerator.returnOK(achievementService.getAchievementPolicyDetail(policyNumber));
	}

	@ApiOperation(value = "查询个人业绩排名")
	@PostMapping("/getPersonalAchievementRankingList")
	@MyLog(systemFunctionName = "个人业绩",systemFunctionUrl = "/personalAchievementController/getPersonalAchievementRankingList",userOperationType = 4,userOperationSummary = "查询个人业绩排名")
	public BaseResponse<AchievementRankingBO> getPersonalAchievementRankingList(
			@RequestBody AchievementRankingVO achievementRankingVO) {
		logger.info("查询个人业绩排名");
		return RespGenerator.returnOK(achievementService.getAchievementRank(achievementRankingVO));
	}

	@ApiOperation(value = "查询产品销量排名")
	@PostMapping("/getProductSalesRankingList")
	@MyLog(systemFunctionName = "个人业绩",systemFunctionUrl = "/personalAchievementController/getProductSalesRankingList",userOperationType = 4,userOperationSummary = "查询产品销量排名")
	public BaseResponse<ProductSaleRankingBO> getProductSalesRankingList(
			@RequestBody AchievementRankingVO achievementRankingVO) {
		logger.info("查询产品销量排名");
		return RespGenerator.returnOK(achievementService.getProductSalesRankingList(achievementRankingVO));
	}
}
